//
//  PermissionsDialogHelper.hpp
//  client
//
//  Created by ming on 2019/4/10.
//

#ifndef PermissionsDialogHelper_hpp
#define PermissionsDialogHelper_hpp

#include "cocos2d.h"
#include "extensions/cocos-ext.h"
USING_NS_CC;



class PermissionsDialogHelper:public Ref {
public:
    typedef std::function<void(int)> PermissionsDialogHelperCallback;
public:
    static PermissionsDialogHelper * create(const char * permissionsStr, const char * grantedFailStr, const char * grantedFailAndForbidStr, const PermissionsDialogHelperCallback & successCb);
    PermissionsDialogHelper();
    virtual ~PermissionsDialogHelper();
    
    void requestPermissions();
    void setGrantedFailAndForbidStr(const char * str){_grantedFailAndForbidStr = str;}
    void setGrantedFailStr(const char * str){_grantedFailStr = str;}
    void setPermissionsStr(const char * str){_permissionsStr = str;}
    
    void setSuccessCallback(const PermissionsDialogHelperCallback & callback){_successCallback = callback;};
    void setFailCallback(const PermissionsDialogHelperCallback & callback){_failCallback = callback;};
    
    void showGrantedFailDialog();
    
    void showGrantedFailAndForbidDialog();
private:
    void _removeEventListen();
    void _addEventListen();

    
    std::string _grantedFailAndForbidStr; // 被禁止弹出之后 显示文本
    std::string _grantedFailStr; // 
    std::string _permissionsStr;
    
    EventListenerCustom* _listener;
    PermissionsDialogHelperCallback _successCallback;
    PermissionsDialogHelperCallback _failCallback;
};

#endif /* PermissionsDialogHelper_hpp */
